<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('编辑水电师傅')" />
    <th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="main-content">
        <form>
        <div class="col-md-12">
            <input type="hidden" id="userId" th:value="${user.userId}">
            <div class="form-group">
                <label class="col-sm-3 control-label">客户名称：</label>
                <div class="col-sm-9">
                    <input type="text" id="userName" class="form-control" th:value="${user.userName}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">水电师傅：</label>
                <div class="col-sm-9">
                    <select id="workerId" class="form-control">
                        <option th:each="worker:${workerList}" th:text="${worker.userName}" th:value="${worker.userId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系方式：</label>
                <div class="col-sm-9">
                    <input type="text" id="phonenumber" class="form-control"  th:value="${user.phonenumber}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注信息：</label>
                <div class="col-sm-9">
                    <textarea type="text" id="remark" class="form-control"  th:text="${user.remark}"></textarea>
                </div>
            </div>
            <div class="form-group">
                <p>&nbsp;</p>
            </div>
        </div>
        </form>
    </div>
    <div class="row col-sm-12">
        <div class="col-sm-8 pull-right">
            <button type="button" class="btn btn-primary" onclick="editSave()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-danger" onclick="$.modal.close()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
	<script th:inline="javascript">
        var user = [[${user}]];
	    function editSave() {
            $.ajax({
                type: "post",
                url: ctx + "hh/user/userEdit",
                data: {
                    "userId": $("#userId").val(),
                    "userName": $("#userName").val(),
                    "phonenumber": $("#phonenumber").val(),
                    "roleId": user.roles[0].roleId,
                    "workerId": $("#workerId").val(),
                    "remark": $("#remark").val(),
                },
                success: function (r) {
                    if (r.code == 0) {
                        $.modal.close();
                    } else {
                        $.modal.closeLoading();
                        $('.imgcode').click();
                        $(".code").val("");
                        $.modal.msg(r.msg);
                    }
                }
            })
        }
    </script>
</body>
</html>